#include<bits/stdc++.h>
using namespace std;
const int NN=1e6+4;
int a[NN];
int main()
{
    freopen("permutation.in","r",stdin);
    freopen("permutation.out","w",stdout);
    int n,r;
    scanf("%d%d",&n,&r);
    a[1]=3,a[2]=1,a[3]=2;
    for(int i=4;i<=n;i++)
        a[i]=i;
    do
    {
        long long s=0;
        bool flag=true;
        for(int i=1;i<n;i++)
        {
            s+=a[i];
            if(s<a[i+1])
            {
                flag=false;
                break;
            }
        }
        r-=flag;
        if(!r)
            for(int i=1;i<=n;i++)
                printf("%d ",a[i]);
    }while(next_permutation(a+1,a+1+n));
    return 0;
}